package com.lkx.web;

import com.alibaba.fastjson.JSON;
import com.lkx.domain.DemoGoodsStatistics;
import com.lkx.domain.GoodsStatistics;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: GoodsController
 * Function:  TODO
 * Date:      2019-10-31 14:50
 * author     likaixuan
 * version    V1.0
 */
@RestController
public class GoodsController {
    private static Logger log = LoggerFactory.getLogger(GoodsController.class);

    @Autowired
    private DefaultMQProducer defaultMQProducer;

    @RequestMapping("/goodsAdd1")
    public int add(){
        DemoGoodsStatistics goodsStatistics = new DemoGoodsStatistics();
        goodsStatistics.setGoodsId1(new Long(197));
        goodsStatistics.setGoodsId2(new Long(198));
        Message sendMsg = new Message("DemoTopic", "DemoTag1", JSON.toJSONBytes(goodsStatistics));
        try {
            SendResult sendResult = defaultMQProducer.send(sendMsg);
        } catch (Exception e) {
        }
        return 1;
    }

    @RequestMapping("/goodsAdd2")
    public int add2(){
        DemoGoodsStatistics goodsStatistics = new DemoGoodsStatistics();
        goodsStatistics.setGoodsId1(new Long(198));
        goodsStatistics.setGoodsId2(new Long(197));
        Message sendMsg = new Message("DemoTopic", "DemoTag1", JSON.toJSONBytes(goodsStatistics));
        try {
            SendResult sendResult = defaultMQProducer.send(sendMsg);
        } catch (Exception e) {
        }
        return 1;
    }
}
